package com.zretc.controller;

import com.github.pagehelper.PageInfo;
import com.zretc.entity.*;
import com.zretc.service.FilmService;
import com.zretc.service.FrontMovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 王兴杭
 * 前端电影页面模块
 */
@Controller
@RequestMapping("front")
public class FrontMovieController {

    @Autowired
    private FrontMovieService frontMovieService;
    @Autowired
    private FilmService filmService;

    @GetMapping("/findtype")
    @ResponseBody
    public List<FilmType> findType(){

        List<FilmType> fileTypeName = frontMovieService.findFileTypeName();
        return fileTypeName;
    }

    @GetMapping("/findReleaseTime")
    @ResponseBody
    public List<String> findReleaseTime(){

        List<String> ReleaseTime = frontMovieService.findfilmReleaseTime();
        return ReleaseTime;
    }

    @GetMapping("/findactor")
    @ResponseBody
    public List<Actor>  findActor(){

        List<Actor> actor = frontMovieService.findActor();
        return actor;
    }

    @ResponseBody
    @GetMapping("/movie")
    public PageInfo<FilmAndComment> getFilm(String pageNum,
                                             String pageSize,
                                             String filmName,
                                             String filmReleaseTime,
                                             String actorName,
                                             String filmTypeName) {
        Map<String, String> map = new HashMap<>();
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        map.put("filmName",filmName);
        map.put("filmReleaseTime",filmReleaseTime);
        map.put("actorName",actorName);
        map.put("filmTypeName",filmTypeName);
        map.put("filmStatus","0");
        PageInfo<FilmAndComment> filmPageInfo = frontMovieService.fidndfilm(map);
        return filmPageInfo;
    }


}
